'use strict';
module.exports = {
	/**
	 * 用户收藏课程列表
	 * @url client/course/pub/my_course_collection 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, pageIndex = 1, pageSize = 10 } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		res = await vk.baseDao.selects({
			dbName: "user-star",
			getMain: false, // 是否只返回rows数据
			pageIndex: pageIndex,
			pageSize: pageSize,
			foreignDB: [{
				dbName: "course",
				localKey: "course_id",
				foreignKey: "_id",
				as: "detail",
				limit: 1,
				foreignDB: [{
					dbName: "course_videos",
					localKey: "_id",
					foreignKey: "course_id",
					as: "videos",
					fieldJson: { render_desc: false }
				}]
			}],
			sortArr: [{ "name": "_add_time", "type": "desc" }],
			whereJson: {
				user_id: uid
			},
		});
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
